package com.example.ordersys.config;

import com.example.ordersys.model.UserInfo;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

// 保存全局常量
public class AppFinal {
    // 用户 session key
    public static final String USERINFO_SESSIONKEY = "userinfo";
    //sessionid
    public static UserInfo getUserBySession(HttpServletRequest httpServletRequest){
        UserInfo userInfo=null;
        HttpSession session = httpServletRequest.getSession(false);
        if (session!=null)
            userInfo= (UserInfo) session.getAttribute(AppFinal.USERINFO_SESSIONKEY);
        return userInfo;
    }
}